From 8bdcfa68ef8414438e596cc6626dafb289547e29 Mon Sep 17 00:00:00 2001 From: Christian Korber Date: Mon, 29 Jul 2024 13:39:46 +0200 Subject: [PATCH] luci-app-snmpd: add SNMPv3 tab This commit introduces a new tab with SNMPv3 options to set. Authentication and encryption parameters can be set needed for net-snmp's snmpd.conf in /var/run. Signed-off-by: Christian Korber --- .../luci-static/resources/view/snmpd/snmpd.js | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/applications/luci-app-snmpd/htdocs/luci-static/resources/view/snmpd/snmpd.js b/applications/luci-app-snmpd/htdocs/luci-static/resources/view/snmpd/snmpd.js index cc6c9492dc..858a9056d6 100644 --- a/applications/luci-app-snmpd/htdocs/luci-static/resources/view/snmpd/snmpd.js +++ b/applications/luci-app-snmpd/htdocs/luci-static/resources/view/snmpd/snmpd.js @@ -152,6 +152,81 @@ return L.view.extend({ } }, + populateV3Settings: function(tab, s){ + let g, go, o; + + o = s.taboption(tab, form.SectionValue, '__v3__', + form.GridSection, 'v3', + null, _('Here you can configure SNMPv3 settings')); + + g = o.subsection; + g.anonymous = true; + g.addremove = true; + g.nodescriptions = true; + g.modaltitle = 'SNMPv3'; + + go = g.option(form.Value, 'username', + _('username'), + _('Set username to access SNMP')); + go.rmempty = false; + go.optional = false; + go.modalonly = true; + + go = g.option(form.Flag, 'allow_write', + _('Allow write')); + go.rmempty = false; + go.default = '0'; + + go = g.option(form.ListValue, 'auth_type', + _('SNMPv3 authentication type')); + go.value('', _('none')); + go.value('SHA', _('SHA')); + go.value('MD5', _('MD5')); + go.rmempty = true; + go.default = 'SHA'; + + // SNMPv3 auth pass + go = g.option(form.Value, 'auth_pass', + _('SNMPv3 authentication passphrase')); + go.password = true; + go.rmempty = true; + go.modalonly = true; + go.optional = false; + go.depends({'auth_type': '', '!reverse': true}); + + // SNMPv3 privacy/encryption type + go = g.option(form.ListValue, 'privacy_type', + _('SNMPv3 encryption type')); + go.value('', _('none')); + go.value('AES', _('AES')); + go.value('DES', _('DES')); + go.rmempty = true; + go.default = 'AES'; + + // SNMPv3 privacy/encryption pass + go = g.option(form.Value, 'privacy_pass', + _('SNMPv3 encryption passphrase')); + go.password = true; + go.rmempty = true; + go.modalonly = true; + go.optional = false; + go.depends({'privacy_type': '', '!reverse': true}); + + go = g.option(form.ListValue, 'RestrictOID', + _('OID-Restriction')); + go.value('no', _('No')); + go.value('yes', _('Yes')); + go.default = 'no'; + go.optional = false; + go.rmempty = false; + + this.oid = g.option(form.Value, + 'RestrictedOID', + _('OID')); + this.oid.datatype = 'string'; + this.oid.depends('RestrictOID', 'yes'); + }, + render: function(data) { let m, s, o, g, go; @@ -296,6 +371,9 @@ return L.view.extend({ this.populateV1V2CSettings('access_HostIP', _('Communities via IP-Address range'), 'HostIP', s); + s.tab('v3', _('SNMPv3')); + this.populateV3Settings('v3', s); + return m.render(); }, -- 2.30.2